﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/TemplateUser.Master" Inherits="System.Web.Mvc.ViewPage" %>
<%@ Import Namespace="ManageBanking.Models" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">


    <script src='<%=Url.Content("~/Scripts/jquery.validate.js") %>' type="text/javascript"></script>

    <script src="../../../../Scripts/wysiwyg.js" type="text/javascript"></script>

    <link href="../../../../Content/css/SucErr1.css" rel="stylesheet" type="text/css" />
    <script src="../../../../Scripts/functions.js" type="text/javascript"></script>
	<script language="javascript" type="text/javascript">
	    $(document).ready(function() {

	        $('#f1').validate({
	            rules: {
	                ToAccount: {
	                    required: true
	                },
	                money: {
	                    required: true,
	                    number:true
	                }
	                
	            }, //ket thuc rules
	            messages: {
	            ToAccount: {
	                required: "The Destination Account can not be null"
	            },
	            money: {
	                required: "The Money to Transfer must not be null",
	                number: "Money Must Be Number"
	            }
	            }
	        });  // ket thuc validate

	        


	    });           // ket thuc ready
    </script>
    
    <script type="text/javascript">

        var a = 0;
        var b = 0;
        var c = 0;
        $(document).ready(function() {

            $("#money").keyup(function() {
                var status = $("#divcheck");
                status.html("");
                a == 0;
                $('#a').attr("value", 0);

            });
            $("#money").blur(function() {

                var name = $("#money").val();
                var name1 = $("#ttmoney").val();

                var status = $("#divcheck");

                status.html("Checking....").removeClass(); ;

                $.post("/T_Account/CheckMoney", { money: name, ttmoney: name1 },

                    function(data) {

                        if (data == true) {

                            status.html("Money is Valid!!!!!!").addClass("green");
                            a == 1;
                            $('#a').attr("value", 1);

                        } else {

                            status.html("Money Is Invalid!!!!!!").addClass("red");
                            a == 0;
                            $('#a').attr("value", 0);
                        }

                    });

            });
            $('#f1').submit(function() {
                a = $('#a').attr("value");
                b = $('#b').attr("value");

                if (b == 0) {
                    alert("Please Check Destination Account,Or It's Invalid");
                    return false;
                }
                else if (a == 0) {
                    alert("Pleae Check Money Transfer,Or It's Invalid");
                    return false;
                }
                else if (a == 1 && b == 1) {
                    var money = $('#money').attr("value");
                    var toacc = $('#ToAccount').attr("value");

                    
                   
                    if(confirm('Are you sure transfer' + money + 'to Account' + toacc))
                  

                    return true;
                }
                return false;
            });

        });
    </script>
    <script type="text/javascript">

        $(document).ready(function() {

            $("#ToAccount").keyup(function() {
                var status = $("#DivMoney");
                status.html("");
                $('#b').attr("value", 0);
            });
            $("#ToAccount").blur(function() {

                var name = $("#ToAccount").val();
                var name1 = $("#idacc").val();
                var status = $("#DivMoney");

                status.html("Checking....").removeClass(); ;

                $.post("/T_Account/CheckIdAccount", { ToAccount: name, idacc: name1 },

                    function(data) {

                        if (data == true) {

                            status.html("Idaccount is Valid!!!!!").addClass("green");
                            $('#b').attr("value", 1);

                        } else {

                        status.html("Idaccount is not Valid!!!!!").addClass("red1");
                            $('#b').attr("value", 0);

                        }

                    });

            });

        });
    </script>
      <style type="text/css">
       .ui-autocomplete
       {
       
       	margin-left:760px;
       	margin-top:208px
              
       }
        .green

        {
            float:left;
            color: Green;
            margin-left:218px;
            margin-top:-9px;
        }

        .red

        {   float:left;
            margin-left:168px !important;
            color: Red;
            margin-top:-9px;
        }
        .red1

        {   float:left;
            margin-left:2px !important;
            color: Red;
            margin-top:-9px;
        }
        #divcheck
        {
        float:left;
        margin-left:14px;
        margin-top:-9px;	
        }
        .btnCheck
        {
        margin-left:11px;	
        	
        }
        .spancenter
        {
        margin-left:-64px;	
        }
    </style>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

 
 <% string id= (string) ViewData["idaccount"] ;
   decimal money = (decimal)ViewData["money"];  %>
  
    <%using (Html.BeginForm("ResolveTransfer", "T_Account", FormMethod.Post, new { @id = "f1" }))
      {
           %>    
    <div class="center_block_top"><span>&nbsp;</span><h3>Transfer Money</h3></div>
            <div class="center_block_mau"><!--section-->
	        <div id="intro">
            <blockquote>
               <% if (ViewData["ss"] == "true")
              {
                  %>
         <div class="succes">
					<div class="succes_icon"><!-- --></div>
					<a href="#" class="close" title="Close this notification">x</a>
					<div class="desc">
						<span>Success!</span>
						<p>Congarulation,Your Action Is Success</p>
					</div>
				</div>
				<div class="clear"><!-- --></div>   
				<%} %>
				<%else if (ViewData["ss"]!=null){ %>
				<div class="err">
					<div class="err_icon"><!-- --></div>
					<a href="#" class="close" title="Close this notification">x</a>
					<div class="desc">
						<span>Error!</span>
						<p><%=ViewData["ss"] %></p>
					</div> 
				</div>
				<%} %>
            <div class="redistry">
                <input id="Hidden1" name="idaccount"  type="hidden" value="<%=id %>" />
                <input id="Hidden2" type="hidden" name="totalmoney" value="<%=money %>"  />
                <input id="a" type="hidden" />
                 <input id="b" type="hidden" />
            <ul>
            
                <li>
            	    <span>Your Account:</span>
            	    <span class="spancenter"><%= ViewData["idaccount"]%></span>
                    <input id="idacc" name="idacc" value="<%= ViewData["idaccount"] %>" type="hidden" />
                    <input id="ttmoney" name="ttmoney"  value="<%= ViewData["money"] %>" type="hidden" />
            	</li>
            	<li>
            	    <span>Total Money:</span>
            	    <span class="spancenter"><%= ViewData["money"]%></span>
            	</li>
            	    
                <li>
            	    <span>The Des Account:</span>
            	    <div class="input_text"></div>
            	    <div><input name="ToAccount" id="ToAccount" type="text" size="20" /></div>
            	     
                <div id="DivMoney" class="error" visible="true"></div>
            	    </li>
                <li>
            	    <span>Transfer Money:</span>
            	    <div class="input_text"></div>
            	    <div><input name="money" id="money" type="text" size="20" /></div>
                    
                <div id="divcheck" class="error" visible="true"></div>
                   </li>
            <li>
            	    <span>Pass Tras</span>
            	    <div class="input_text"></div>
            	    <div><input name="pass" id="Text1" type="password" size="20" /></div>
                   
                </li>
            
           
             <li class="Content">
            	<span>&nbsp;</span>
                <ul>
                	<li ><input type="submit" id="sub1" name="button" value="OK" class="ok"/></li>
                	<%} %>
                    <li id="cancel" ><input type="reset" name="button" value="Reset" class="ok" /></li>
                </ul>
            </li>
            
            </ul>
            </div>
          
            </blockquote>
            <div class="clearBoth"></div>
            <blockquote>
 
</blockquote>
</div>
<!--//intro-->
</div>
<div class="center_block_bottom_mau"></div>

  
</asp:Content>
